<!--
试题管理查看
 add by yyp 2019-06-05
-->
<template lang="pug">
  kalix-dialog.user-add(title='查看' bizKey="TestQuestion" ref="kalixBizDialog"  v-bind:formModel.sync="formModel" isView)
    div.el-form(slot="dialogFormSlot")
      el-form-item(label="创建人名" prop="userName" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.userName" readonly)
      el-form-item(label="题库类别" prop="bankCategoryType" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.bankCategoryType" readonly)
      el-form-item(label="题目类型" prop="subjectType" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.subjectType" v-on:input="change($event)"  readonly)
      el-form-item(label="试题难度" prop="difficulty" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.difficulty" readonly)
      el-form-item(label="题目" prop="exerciseProblem" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.exerciseProblem" readonly)
      el-form-item(v-if="formModel.subjectType === '单选题'? false : (formModel.subjectType === '多选题'? false : true)"  label="回答" prop="exerciseAnswer" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.exerciseAnswer" readonly)
      el-form-item(v-if="formModel.subjectType === '单选题'? true : (formModel.subjectType !== '多选题'? false : true) " label="选项A" prop="optionA" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.optionA")
      el-form-item(v-if="formModel.subjectType === '单选题'? true : (formModel.subjectType !== '多选题'? false : true) " label="选项B" prop="optionB" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.optionB")
      el-form-item(v-if="formModel.subjectType === '单选题'? true : (formModel.subjectType !== '多选题'? false : true) " label="选项C" prop="optionC" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.optionC")
      el-form-item(v-if="formModel.subjectType === '单选题'? true : (formModel.subjectType !== '多选题'? false : true) " label="选项D" prop="optionD" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.optionD")
      el-form-item(label="试题图片" prop="imgUrl" v-bind:label-width="labelWidth")
      kalix-img-upload.img-margin(v-model="formModel.imgUrl" readonly="readonly")
</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import {baseURL} from '../../../../../config/global.toml'
  import KalixSelect from '../../../../../components/corelib/components/common/baseSelect'
  import KalixImgUpload from '../../../../../components/corelib/components/common/imgUpload'
  export default {
    name: 'testquestionView',
    components: {
      KalixSelect,
      KalixClansmanUpload,
      KalixImgUpload
    },
    data() {
      return {
        action: baseURL + '/camel/rest/upload',
        formModel: Object.assign({}, FormModel),
        labelWidth: '120px',
        daa: true,
        xxa: true
        // subjectTypes: this.formModel.subjectType
      }
    },
    mounted() {
      this.aaa()
    },
    methods: {
      aaa() {
        // if (this.subjectTypes === '单选题') {
        //   console.log(111)
        // }
        console.log('aaaaa', this.formModel.subjectType)
      },
      change(item) {
        if (item === '单选题' || item === '多选题') {
          this.daa = false
          this.xxa = true
        } else {
          this.daa = true
          this.xxa = false
        }
      },
      ImgDel(imgUrl) {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
          center: true
        }).then(() => {
          let arrImg = this.formModel.imgUrl.split(',')
          console.log('arrImg++++++++++++++', arrImg)
          let idx = arrImg.indexOf(imgUrl)
          arrImg.splice(idx, 1)
          this.formModel.imgUrl = arrImg.join(',')
          console.log('this.formModel.imgUrl++++++++++++++', this.formModel.imgUrl)
          // this.filePathArr = arrImg
          this.$message({
            type: 'success',
            message: '删除成功!'
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
      },
      init(dialogOption) {
        console.log('---------dialogOption------------', dialogOption)
      },
      getArray(val) {
        return val.split(',')
      },
      getFilePath(filePath, fileName) {
        console.log('--getFilePath---', filePath)
        console.log('--fileName---', fileName)

        this.formModel.imgUrl = filePath
        this.formModel.imgName = fileName
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .el-form
    width 50%
    margin auto
    .radio
      margin-left 150px
      margin-bottom 20px
      .el-radio
        color: #3465cb
        font-weight: bold
        font-size: 14px
  .img-margin
    margin-left 150px
</style>
